﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;

namespace RMD.Modal
{
    public class DBVoucherRepository : IVoucherRepository
    {
        #region IVoucherRepository Members

        public IList<Voucher> GetVouchers()
        {
            ISession session = NHHelper.GetNHSession();
            ICriteria crit = session.CreateCriteria<Voucher>();
            return crit.List<Voucher>();
        }

        public void AddVoucher(Voucher voucher)
        {
            ISession session = NHHelper.GetNHSession();
            ITransaction tx = session.BeginTransaction();
            session.SaveOrUpdate(voucher);
            //session.Flush();
            tx.Commit();
            session.Close();
        }

        #endregion
    }
}
